home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3p / taskblock.z / taskblock
Encoding:
Text File  |  1998-10-20  |  4.1 KB  |  133 lines

  1.  
  2.  
  3.  
  4. TTTTAAAASSSSKKKKBBBBLLLLOOOOCCCCKKKK((((3333PPPP))))                                                    TTTTAAAASSSSKKKKBBBBLLLLOOOOCCCCKKKK((((3333PPPP))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      taskblock, taskunblock, tasksetblockcnt - routines to block/unblock tasks
  10.  
  11. CCCC SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ####iiiinnnncccclllluuuuddddeeee <<<<ssssyyyyssss////ttttyyyyppppeeeessss....hhhh>>>>
  13.      ####iiiinnnncccclllluuuuddddeeee <<<<ttttaaaasssskkkk....hhhh>>>>
  14.  
  15.      iiiinnnntttt ttttaaaasssskkkkbbbblllloooocccckkkk ((((ttttiiiidddd____tttt ttttiiiidddd))));;;;
  16.  
  17.      iiiinnnntttt ttttaaaasssskkkkuuuunnnnbbbblllloooocccckkkk ((((ttttiiiidddd____tttt ttttiiiidddd))));;;;
  18.  
  19.      iiiinnnntttt ttttaaaasssskkkksssseeeettttbbbblllloooocccckkkkccccnnnntttt ((((ttttiiiidddd____tttt ttttiiiidddd,,,, iiiinnnntttt ccccoooouuuunnnntttt))));;;;
  20.  
  21. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  22.      These routines provide a complete set of blocking/unblocking capabilities
  23.      for tasks.  Blocking is implemented via a counting semaphore in the
  24.      system.  Each call to _t_a_s_k_b_l_o_c_k decrements the count and, if it goes
  25.      negative, the task is suspended.  When _t_a_s_k_u_n_b_l_o_c_k is called, the count
  26.      is incremented, and if it goes positive (or zero), the task is re-
  27.      started.  This provides both a simple, race free synchronization ability
  28.      between two tasks, as well as a much more powerful capability to
  29.      synchronize multiple tasks.
  30.  
  31.      In order to guarantee a known starting place the _t_a_s_k_s_e_t_b_l_o_c_k_c_n_t function
  32.      may be called which will force the semaphore count to the value given by
  33.      _c_o_u_n_t. New tasks have their semaphore zeroed.  Normally, _c_o_u_n_t should be
  34.      set to 0.  If the resulting block count is greater than or equal to zero
  35.      and the task is currently blocked, it will be unblocked.  If the
  36.      resulting block count is less than zero, the task will be blocked.  Using
  37.      this, a simple rendezvous mechanism can be set up.  If one task wanted to
  38.      wait for _n other tasks to complete, it could set its block count to -_n.
  39.      This would immediately force the task to block.  Then as each task
  40.      finishes it unblocks the waiting task.  When the _n'_t_h task finishes the
  41.      waiting task will be woken.
  42.  
  43.      A task may block another task provided that standard UNIX permissions are
  44.      satisfied.
  45.  
  46.      These routines will fail and no operation will be performed if one or
  47.      more of the following are true:
  48.  
  49.      [EINVAL]
  50.           The _t_i_d specified is not a valid task id.
  51.  
  52.      [EPERM]
  53.           The caller is not operating on itself, its effective user ID is not
  54.           super-user, and its real or effective user ID does not match the
  55.           real or effective user ID of the to be acted on task.
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. TTTTAAAASSSSKKKKBBBBLLLLOOOOCCCCKKKK((((3333PPPP))))                                                    TTTTAAAASSSSKKKKBBBBLLLLOOOOCCCCKKKK((((3333PPPP))))
  71.  
  72.  
  73.  
  74. SEE ALSO
  75.      blockproc(2), taskdestroy(3P), taskctl(3P), taskcreate(3P).
  76.  
  77. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  78.      Upon successful completion, 0 is returned.  Otherwise, a value of -1 is
  79.      returned to the calling task, and _e_r_r_n_o is set to indicate the error.
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.